﻿@model Mrc.Entity.SysUser
@{
    ViewData["Title"] = "Add";
    Layout = "~/Areas/Admin/Views/_Layout.cshtml";
    var Orgs = ViewBag.orgs as List<Mrc.Entity.SysOrg>;
    var roles = ViewBag.roles as List<Mrc.Entity.SysRole>;
    var posts = ViewBag.posts as List<Mrc.Entity.SysPost>;
    var orgIds=Model.OrgIds.Split(',').ToArray();
    var postIds = Model.PostIds.Split(',').ToArray();
    var roleIds = Model.RoleIds.Split(',').ToArray();
    var Id = (ViewContext.HttpContext.Request.Query["Id"]).ToString();
}
<link href="~/lib/layui-select/formSelects-v4.css" rel="stylesheet" />
<div style="margin-top:3em;margin-right:5em">
    <form class="layui-form" action="">
        <div class="layui-form-item">
                <label class="layui-form-label">账号</label>
                <div class="layui-input-block">
                    <input type="text" name="accountName" value="@Model.AccountName" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-block">
                    <input type="text" name="name" value="@Model.Name" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input type="text" name="mobilePhone" value="@Model.MobilePhone" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">邮箱</label>
                <div class="layui-input-block">
                    <input type="text" name="email" value="@Model.Email" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">生日</label>
                <div class="layui-input-block">
                    <input type="text" name="birthday" id="birthday"  value="@Model.Birthday" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <input type="radio" name="gender" value="0" title="女" @(((Model.Gender??0)==Mrc.Entity.Gender.Woman)?"checked":"")>
                <input type="radio" name="gender" value="1"  title="男" @(((Model.Gender??0)==Mrc.Entity.Gender.Man)?"checked":"")>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">组织</label>
            <div class="layui-input-block">
                <select name="orgIds" xm-select="select1">
                    @foreach (var item in Orgs)
                    {
                        <option value="@item.Id" @(orgIds.Contains(item.Id)?"selected":"")>@item.Name</option>                    
                    }
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">岗位</label>
            <div class="layui-input-block">
                <select name="postIds" xm-select="select2">
                    @foreach (var item in posts)
                    {
                        <option value="@item.Id" @(postIds.Contains(item.Id)?"selected":"")>@item.Name</option>
                    }
                </select>
            </div>
        </div>
        <div class="layui-form">
            <label class="layui-form-label">角色</label>
            <div class="layui-input-block">
                <select name="roleIds" xm-select="select3">
                    @foreach (var item in roles)
                    {
                        <option value="@item.Id" @(roleIds.Contains(item.Id)?"selected":"")>@item.Name</option>
                    }
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text" style="margin-top:1em">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea name="description"  placeholder="请输入内容" class="layui-textarea">@Model.Description</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>

<script>
    //全局定义一次, 加载formSelects
    layui.config({
        base: '/lib/layui-select/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        formSelects: 'formSelects-v4'
    });
    layui.use(['form', 'laydate','formSelects'], function(){
        var form = layui.form;
        var laydate = layui.laydate;
        var formSelects = layui.formSelects;
        //执行一个laydate实例
        laydate.render({
            elem: '#birthday' //指定元素
        });
        //监听提交
        form.on('submit(formDemo)', function (data) {
            BaseAjax('post', "/admin/user/update", data.field, function (repo) {
                if (repo.status == ajaxStatus.OK)
                    x_admin_close();
            })
          return false;
      });
});
</script>

